//轮播图
$(function(){
    $(window).on('resize',function(){
        let cliteW = $(window).width();//获取屏幕滚动时的宽度
        let screenSize = cliteW >800; //根据屏幕大小决定图片怎么处理
        $('#carousel-img div').each(function(index,items){//遍历轮播图中的图片

            let ImgSrc = screenSize ? $(items).data('lg-img') : $(items).data('sm-img');//判断屏幕大小取什么图片
            let ImgUrl = "url("+ImgSrc+")";//图片URL
            $(items).css({
                backgroundImage:ImgUrl
            });
            
            if (screenSize==false){ /* 给小屏幕添加图片 */
                $img = "<img src='"+ ImgSrc +"'></img>";
                 $(items).empty().append($img);
             }else{
                $(items).empty();
             }
            
         })
    })
    $(window).trigger('resize');





//产品选项卡动态宽度
    $(window).on('resize',function (){
        let $ul=$('#product-tabs');//获取产品tabs的ul
        let $lis = $('[role="presentation"]',$ul);
        let allListW=0;
        $lis.each(function (index,list){
            let $listW = $(list).width();
            allListW+=$listW;
        });
        let $ulW = $ul.width();
        /* console.log('ul列表宽' + $ulW+'\n'+ 'list总宽' + allListW); */

        let $overflow = $('product--overflow')
        if (allListW > $ulW){
            $ul.css({
                width:allListW + 'px'
            });
        }else{
            $overflow.removeAttr('style');
            $ul.css({
                width:'100%'
            });
            /* console.log($ul.parent().attr('style')); */
        }
        
        
    });
    $(window).trigger('resize');


});

//尾部工具提示
$(function () {
    $('[data-toggle="tooltip"]').tooltip()
  })




//导航栏锚点Jquery事件
$(function(){
    

    
    let $lis = $('#bootom-bar__ul li');
    //课程介绍
    $($lis[1]).on('click',function (){
       let $productTop = $('.products').offset().top
        $('html').animate({
            scrollTop:$productTop
        },1000)
    });
    //热门课程
    $($lis[2]).on('click',function (){
       let $hotLessonTop = $('.hot-class').offset().top
        $('html').animate({
            scrollTop:$hotLessonTop
        },1000)
    });
    
    //联系我们
    $($lis[5]).on('click',function (){
       let $contactUsTop = $('.footer').offset().top
        $('html').animate({
            scrollTop:$contactUsTop
        },1000)
    });


})